Fast mode-searching apparatus and method for fast motion-prediction

ABSTRACT

Provided is a fast mode-searching apparatus and method for motion-prediction. The fast mode-searching apparatus includes a probability information obtaining unit, a first inter mode searching unit, a second inter mode searching unit, and a selective intra mode searching unit. The probability information obtaining unit detects whether at least one of a macroblock of a previous frame, a macroblock of a current frame, and adjacent macroblocks corresponds to at least one of P16×16, P16×8, and P8×16. The first inter mode searching unit performs an inter mode search on a block that is not detected by the probability information obtaining unit. The second inter mode searching unit determines whether the macroblock of the current frame corresponds to P16×16 as a result of performing the inter mode search on a block detected by the probability information obtaining unit. The selective intra mode searching unit performs an intra mode search if the macroblock of the current frame corresponds to P16×16.

CROSS-REFERENCE TO RELATED PATENT APPLICATION

This application claims the benefit of Korean Patent Application No.10-2005-0105483, filed on Nov. 4, 2005, in the Korean IntellectualProperty Office, the disclosure of which is incorporated herein in itsentirety by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a fast variable-mode determining methodrequired for motion estimation of a macroblock of a P-frame duringH.264/AVC video compression.

2. Description of the Related Art

According to the H.264/AVC standard, to reduce residual data for animprovement in compression efficiency, a 16×16 macroblock is dividedinto sub-blocks, motion is searched in each of the sub-blocks, and amode having the smallest error is selected and transmitted.

However, in such a scheme, as the number of divided sub-blocksincreases, the number of motion vectors also increases up to 16. As aresult, it is not possible to divide a macroblock into the smallersub-blocks. Thus, in the H.264/AVC standard, a mode having a smallestnumber of required bits is selected using a rate-distortion (R-D) costfunction and is then transmitted.

According to the H.264/AVC standard, in encoding of a P-frame during avideo compression process, a full search for an intra mode is performedafter a search for an inter mode, so as to determine a mode requiringthe smallest R-D cost as a final mode. However, doing a search for anintra mode in all macroblocks of a P-frame for which a search for aninter mode is already performed requires a large amount of computation.

SUMMARY OF THE INVENTION

To overcome the drawbacks of a full search algorithm for modedetermination, the present invention provides a fast mode-searchingapparatus and method for fast motion-prediction, in which an effectiveclassification method for an inter mode is suggested and the number ofintra mode searches is reduced, thereby allowing fast motion-estimation.

According to one aspect of the present invention, there is provided afast mode-searching apparatus for fast motion-prediction. The fastmode-searching apparatus includes a probability information obtainingunit, a first inter mode searching unit, a second inter mode searchingunit, and a selective intra mode searching unit. The probabilityinformation obtaining unit detects whether at least one of a macroblockof a previous frame, a macroblock of a current frame, and adjacentmacroblocks corresponds to at least one of P16×16, P16×8, and P8×16. Thefirst inter mode searching unit performs an inter mode search on a blockthat is not detected by the probability information obtaining unit. Thesecond inter mode searching unit determines whether the macroblock ofthe current frame corresponds to P16×16 as a result of performing theinter mode search on a block detected by the probability informationobtaining unit. The selective intra mode searching unit performs anintra mode search if the macroblock of the current frame corresponds toP16×16.

The fast mode-searching apparatus may further include a best modedetecting unit selecting a final mode obtained as a result of the intermode search by the first inter mode searching unit or the second intermode searching unit as a best mode if the macroblock of the currentframe does not correspond to P16×16, and selecting a best mode bycomparing a rate-distortion (R-D) cost of a final mode obtained as aresult of the inter mode search by the second inter mode searching unitand an R-D cost of a final mode obtained as a result of the intra modesearch if the macroblock of the current frame corresponds to P16×16.

The probability information obtaining unit may further include atemporal information obtaining unit obtaining time information mode ofthe first P-frame of a current GOP (group-of-picture) by referring tothe last P-frame of a previous GOP.

According to another aspect of the present invention, there is provideda fast mode-searching method for fast motion-prediction. The fastmode-searching method includes detecting whether at least one of amacroblock of a previous frame, a macroblock of a current frame, andadjacent macroblocks corresponds to at least one of P16×16, P16×8, andP8×16, performing a first inter mode search on a block that does notcorrespond to one of P16×16, P16×8, and P8×16, performing a second intermode search on a block that corresponds to one of P16×16, P16×8, andP8×16 and determining whether the macroblock of the current framecorresponds to P16×16, and performing an intra mode search if themacroblock of the current frame corresponds to P16×16.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and other features and advantages of the present inventionwill become more apparent by describing in detail an exemplaryembodiment thereof with reference to the attached drawings in which:

FIG. 1 is a block diagram for explaining video encoding through motionprediction;

FIG. 2 illustrates inter modes and intra modes defined in the H.264/AVCvideo compression standard;

FIG. 3 is a view for explaining a block matching algorithm used formotion prediction in the present invention;

FIG. 4 illustrates a search range window in an adjacent previous frameI(t−1) for a block B_(ij) of a current frame I(t);

FIGS. 5A and 5B illustrate the use of adjacent macroblocks for intermode prediction of a current macroblock;

FIG. 6 illustrates a fast mode-searching apparatus for fastmotion-prediction in a H.264/AVC video encoder according to a preferredembodiment of the present invention;

FIG. 7 is a graph showing an experimentally obtained probability that amacroblock corresponding to an intra mode corresponds to an inter mode;

FIGS. 8 and 9 illustrate a process of obtaining inter mode informationto be referred to for mode prediction; and

FIG. 10 is a flowchart illustrating a fast mode-searching method forfast motion-prediction according to a preferred embodiment of thepresent invention.

DETAILED DESCRIPTION OF THE INVENTION

Hereinafter, a preferred embodiment of the present invention will bedescribed in detail with reference to the accompanying drawings. In thedrawings, the same or similar elements are denoted by the same referencenumerals even though they are depicted in different drawings. In thefollowing description, a detailed description of known functions andconfigurations incorporated herein has been omitted for conciseness.

FIG. 1 is a block diagram for explaining video encoding through motionprediction.

Motion prediction of a current frame of an input video signal will bedescribed with reference to FIG. 1. A block division unit 110 divideseach frame of the input video signal into blocks. A subtraction unit 130subtracts an output of a motion-compensation unit 120 from a currentframe I(t). An output of the subtraction unit 130 is transformed by adiscrete cosine transform (DCT) unit 140. A quantization unit 150quantizes transformed coefficients.

A variable-length coding unit 160 generates a compressed stream usingthe quantized coefficients. An inverse quantization (IQ)/inverse DCT(IDCT) unit 170 inversely quantizes and inversely transforms an outputof the quantization unit 150. An output of the IQ/IDCT unit 170 isreconstructed into the original video after passing through an additionunit 180. A motion-estimation unit 190 performs motion estimation orprediction on the current frame I(t) using the reconstructed video,e.g., a previous frame I(t−1).

FIG. 2 illustrates inter modes and intra modes defined in the H.264/AVCvideo compression standard.

As illustrated in FIG. 2, there are a total of 7 inter modes. Indetermination of a final inter mode, the smallest R-D cost is obtainedfor each inter mode and a mode having the smallest R-D cost isdetermined as the final inter mode.

In intra modes, there are two block sizes. When a block size is 16×16, asearch in 4 directions (modes) is required. When a block size is 4×4, asearch in 9 directions (modes) is required. Like in inter modes, a modehaving the smallest residual data (bitrate) among possible intra modesis determined as a final intra mode. In determination of a best mode,R-D costs of the final inter mode and the final intra mode are comparedand a mode having the smaller R-D cost is determined as a best mode fora current macroblock.

FIGS. 3 through 5B illustrate the use of previously determined modeinformation of a macroblock of a previous frame, previously determinedmode information of a macroblock of a current frame, and previouslydetermined mode information of adjacent macroblocks during fastmotion-prediction using a block matching algorithm in the presentinvention.

FIG. 3 is a view for explaining a block matching algorithm used formotion prediction in the present invention.

The block matching algorithm divides a current frame into several smallN×M blocks (which will be referred to as reference blocks), searchingfor the most similar block (which will be referred to as a matchingblock) by comparing each reference block with various blocks in apredetermined area of a previous frame (an area obtained by movement ofthe reference block by −p through +(p−1) pixels in up/down andright/left directions, which will be referred to as a search area), anddetermines the relative position of the found matching block withrespect to the reference block as a motion vector. Such motionestimation reduces correlation between two frames, thereby reducing theamount of data to be transmitted.

FIG. 4 illustrates a search range window in an adjacent previous frameI(t−1) for a block B_(ij) of a current frame I(t).

As illustrated in FIG. 4, the block matching algorithm divides thecurrent frame I(t) into several reference blocks, searches for a blockthat is most similar to the reference block B_(ij) in a search rangewindow of the previous frame I(t−1), determines the relative position ofthe found block with respect to the reference block B_(ij) as a motionvector, and transmits only a difference between the two blocks and thedetermined motion vector.

FIGS. 5A and 5B illustrate the use of adjacent macroblocks for intermode prediction of a current macroblock.

In FIG. 5A, adjacent macroblocks of a current macroblock of the currentframe I(t) are illustrated for the use of mode information of theadjacent macroblocks for inter mode prediction. In other words,previously determined mode information of a block located above and tothe left of the current macroblock, a block located above the currentmacroblock, a block located to the left of the current macroblock, and ablock located above and to the right of the current macroblock is used.

In FIG. 5B, a macroblock in the previous frame I(t−1), located at thesame position as a current macroblock of the current frame I(t), andadjacent macroblocks of the macroblock are illustrated for inter modeprediction. Mode information of 8 adjacent macroblocks is used for modeprediction of the current macroblock.

FIG. 6 illustrates a fast mode-searching apparatus 600 for fastmotion-prediction in a H.264/AVC video encoder according to a preferredembodiment of the present invention.

The fast mode-searching apparatus 600 includes a probability informationobtaining unit 610, a first inter mode searching unit 620, a secondinter mode searching unit 630, a selective intra mode searching unit640, and a best mode detecting unit 650.

The fast mode-searching apparatus 600 according to the present inventionperforms fast motion-prediction on a current macroblock through thefirst and second inter mode searching units 620 and 630 and theselective intra mode searching unit 640.

More specifically, the probability information obtaining unit 610obtains temporal and spatial contextual information with respect to thecurrent macroblock using a method illustrated in FIGS. 3 through 5B. Acase where at least one of a macroblock of a previous frame, amacroblock of a current frame, and adjacent macroblocks corresponds toat least one of P16×16, P16×8, and P8×16 is detected and a timeinformation mode of the first P-frame of a current group-of-picture(GOP) is obtained with reference to the last P-frame of a previous GOPusing a temporal information obtaining unit (not shown). The temporalinformation obtaining unit will be described in more detail withreference to FIGS. 8 and 9.

The probability information obtaining unit 610 obtains mode predictioninformation for a current macroblock from available adjacent macroblocksof a previous frame and a current frame. To this end, the probabilityinformation obtaining unit 610 uses a score function as follows:

$\begin{matrix}{{{S( {x,y} )} = {{\underset{{({i,j})}{Hpreviousframe}}{Q}{{Bin}_{ij}( M_{ij} )}} + {\underset{{({i,j})}{Hcurrentframe}}{Q}{{Bin}_{ij}( M_{ij} )}}}},} & (1)\end{matrix}$

where Bin_(ij)(M_(ij)) is a counting function that increases a countvalue by 1 when a block mode is one of P16×16, P16×8, and P8×16. Inother words, using Bin_(ij)(M_(ij)), it is determined with how manyadjacent modes are related with P16×16 sub-mode groups. As S(x,y)increases, a probability that a current macroblock is included in theP16×16 sub-mode groups increases.

The probability mode obtaining unit 610 classifies an inter mode intoP16×16 sub-mode groups and P8×8 sub-mode groups using the score functionand searches a current macroblock without estimating a motion vector forany mode.

The probability mode obtaining unit 610 classifies an inter mode intoP16×16 sub-mode groups and P8×8 sub-mode groups as follows:

$\begin{matrix}\{ \begin{matrix}{{{{If}\mspace{14mu}{S( {x,y} )}} > 0},} & {P\; 16 \times 16\mspace{14mu}{sub}\text{-}{mode}\mspace{14mu}{group}\mspace{14mu}{search}} \\{{Otherwise},} & {P\; 8 \times 8\mspace{14mu}{sub}\text{-}{mode}\mspace{14mu}{group}\mspace{14mu}{search}}\end{matrix}  & (2)\end{matrix}$

As can be seen from Equation (2), if at least one block is associatedwith the P16×16 sub-mode groups, a search for the P16×16 sub-mode groupsis performed on a current macroblock.

The first inter mode searching unit 620 performs an inter mode search ona block that does not correspond to any one of P16×16, P16×8, and P8×16,i.e., a block that corresponds to P8×8 sub-mode groups.

The first inter mode searching unit 620 performs a P8×8 inter modesearch, a P8×4 inter mode search, a P4×8 inter mode search, and a P4×4inter mode search on each of blocks included in the P8×8 sub-mode groups(P8×8, P8×4, P4×8, and P4×4). The first inter mode searching unit 620then selects a final mode obtained through the inter mode searches as abest mode.

The second inter mode searching unit 630 performs a P16×16 inter modesearch, a P16×8 inter mode search, and a P8×16 inter mode search on eachof blocks included in the P16×16 sub-mode groups (P16×16, P16×8, andP8×16).

The selective intra mode searching unit 640 performs an intra modesearch if the second inter mode searching unit 630 determines that amacroblock of the current frame corresponds to P16×16.

In general, the number of macroblocks corresponding to an intra mode ina P-frame is 1 or 2. Thus, it is inefficient to search for all possibleintra modes in each block for a small number of intra modes.

Thus, the selective intra mode searching unit 640 solves the problemusing the characteristic of a probability of an intra mode occurring. Inother words, it can be seen that most intra modes appear in P16×16 amonginter modes as illustrated in FIG. 7.

Based on the characteristic of the probability of an intra modeoccurring, the selective intra mode searching unit 640 performs an intramode search only in P16×16 and does not perform an intra mode search inthe other inter modes, instead of searching for an intra mode in allblocks corresponding to an inter mode. In this way, fast mode selectionis possible.

If the second inter mode searching unit 630 determines that a macroblockof the current frame does not correspond to P16×16, the best modedetecting unit 650 detects a final mode obtained by the first inter modesearching unit 620 or the second inter mode searching unit 630 as a bestmode.

If a macroblock of the current frame corresponds to P16×16, i.e., if anintra mode search is required, the best mode detecting unit 650 comparesan R-D cost of a final mode obtained as a result of the inter modesearch by the second inter mode searching unit 630 and an R-D cost of afinal mode obtained as a result of the intra mode search to select abest mode.

In case of a block that does not correspond to P16×16 and does notrequire an intra mode search, a best inter mode is a final mode.

FIG. 7 is a graph showing an experimentally obtained probability that amacroblock corresponding to an intra mode also corresponds to an intermode.

As can be seen from FIG. 7, most intra modes appear in P16×16 amonginter modes. Thus, an intra mode search is performed only in P16×16based on a conditional probability characteristic that can be found in avideo screen and an intra mode search is not performed in the otherinter modes, thereby reducing the number of intra mode searches.

FIGS. 8 and 9 illustrate a process of obtaining inter mode informationto be referred to for mode prediction.

For fast inter-mode searching according to the present invention, modeinformation of adjacent macroblocks in a previous frame is required.However, when a previous frame is an intra frame like P₆ and P₁₀illustrated in FIG. 8, a P-frame immediately following an intra frame ina GOP does not include inter mode information to be referred to becausethe previous frame is intra-coded. Thus, in this case, a new referencemethod is added to use mode information for inter mode prediction in thepresent invention.

As illustrated in FIG. 9, in spite of a time interval of two frames asindicated by 910 and 920, two frames have high correlation. Thus, in thepresent invention, a time information mode for the first P-frame of acurrent GOP is obtained from the last P-frame of a previous GOP.

The probability information obtaining unit 610 obtains a timeinformation mode of the first P-frame of the current GOP from the lastP-frame of the previous GOP.

FIG. 10 is a flowchart illustrating a fast mode-searching method forfast motion-prediction according to a preferred embodiment of thepresent invention.

In operation S1010, it is detected whether at least one of a macroblockof a previous frame, a macroblock of a current frame, and adjacentmacroblocks corresponds to at least one of P16×16, P16×8, and P8×16.

A block corresponding to one of P16×16, P16×8, and P8×16 is classifiedinto P16×16 sub-mode groups and the other blocks are classified intoP8×8 sub-mode groups in operation S1020. At this time, the probabilityinformation obtaining unit 610 of FIG. 6 performs classification using aclassification method like Equation (2).

Thereafter, an inter mode search is performed on the P16×16 sub-modegroups and the P8×8 sub-mode groups in operations S1030 and S1040. If itis determined that a macroblock of a current macroblock corresponds toP16×16 in operation S1050, an intra mode search is performed inoperation S1060.

For a block that does not undergo an intra mode search, a final mode isdetermined as a best mode in operation S1070. For a block that undergoesan intra mode search, an R-D cost of a best inter mode and an R-D costof a best intra mode are compared and a mode having the smaller R-D costis determined as a best mode in operation S1080.

As described above, according to the present invention, an efficientinter mode classification method is suggested to improve a fastmode-searching method. In addition, the number of intra mode searches isreduced using a probability of an intra mode occurring, thereby allowingfast motion-estimation and mode-determination for real-time videocompression.

Moreover, a speed in determining a mode for each block in a H.264/AVCvariable block-based video compression system is improved, contributingto an improvement in a real-time compression function of the videocompression system in terms of software.

Furthermore, by combining the suggested fast mode-searching method and aconventional fast motion vector estimating method, a faster videoencoding system can be implemented.

Meanwhile, the present invention can also be embodied as acomputer-readable code on a computer-readable recording medium. Thecomputer-readable recording medium is any data storage device that canstore data which can be thereafter read by a computer system. Examplesof the computer-readable recording medium include read-only memory(ROM), random-access memory (RAM), CD-ROMs, magnetic tapes, floppydisks, optical data storage devices, and carrier waves. Thecomputer-readable recording medium can also be distributed over networkcoupled computer systems so that the computer-readable code is storedand executed in a distributed fashion.

While the present invention has been particularly shown and describedwith reference to an exemplary embodiment thereof, it will be understoodby those of ordinary skill in the art that various changes in form anddetails may be made therein without departing from the spirit and scopeof the present invention as defined by the following claims.

1. A fast mode-searching apparatus for fast motion-prediction, the fastmode-searching apparatus comprising: a probability information obtainingunit using a score function S(x,y) to determine whether at least one ofa macroblock of a previous frame, a macroblock of a current frame, andadjacent macroblocks corresponds to P16×16 sub-mode groups comprising atleast one of P16×16, P16×8, and P8×16 or corresponds to P8×8 sub-modegroups comprising at least one of P8×8, P8×4, P4×8, and P4×4 in which${S( {x,y} )} = {{\underset{{({i,j})}{Hpreviousframe}}{Q}{{Bin}_{ij}( M_{ij} )}} + {\underset{{({i,j})}{Hcurrentframe}}{Q}{{Bin}_{ij}( M_{ij} )}}}$where Bin_(ij)(M_(ij)) is a counting function that increases a countvalue by 1 when a block mode Is one of P16×16, P16×8, and P8×16, whereinwhen S(x,y)>0 an inter mode is classified into P16×16 sub-mode groupsand otherwise the inter mode is classified into P8×8 sub-mode groups; afirst inter mode searching unit performing an inter mode search on ablock that is not detected by the probability information obtainingunit; a second inter mode searching unit determining whether themacroblock of the current frame corresponds to P16×16 as a result ofperforming the inter mode search on a block detected by the probabilityinformation obtaining unit; and a selective intra mode searching unitperforming an intra mode search if the macroblock of the current framecorresponds to P16×16.
 2. The fast mode-searching apparatus of claim 1,further comprising a best mode detecting unit selecting a final modeobtained as a result of the inter mode search by the first inter modesearching unit or the second inter mode searching unit as a best mode ifthe macroblock of the current frame does not correspond to P16×16, andselecting a best mode by comparing an R-D (rate-distortion) cost of afinal mode obtained as a result of the inter mode search by the secondinter mode searching unit and an R-D cost of a final mode obtained as aresult of the intra mode search if the macroblock of the current framecorresponds to P16×16.
 3. The fast mode-searching apparatus of claim 1,wherein the first inter mode searching unit performs the inter modesearch in P8×8, P8×4, P4×8 and P4×4.
 4. The fast mode-searchingapparatus of claim 1, wherein the second inter mode searching unitperforms the inter mode search in P16×16, P16×8, and P8×16.
 5. The fastmode-searching apparatus of claim 1, wherein the probability informationobtaining unit comprises a temporal information obtaining unit obtainingtime information mode of the first P-frame of a current GOP(group-of-picture) by referring to the last P-frame of a previous GOP.6. A fast mode-searching method for fast motion-prediction, the fastmode-searching method comprising: detecting using a score functionS(x,y) to determine whether at least one of a macroblock of a previousframe, a macroblock of a current frame, and adjacent macroblockscorresponds to P16×16 sub-mode groups comprising at least one of P16×16,P16×8, and P8×16, or corresponds to P8×8 sub-mode groups comprising atleast one of P8×8, P8×4, P4×8, and P4×4 in which${S( {x,y} )} = {{\underset{{({i,j})}{Hpreviousframe}}{Q}{{Bin}_{ij}( M_{ij} )}} + {\underset{{({i,j})}{Hcurrentframe}}{Q}{{Bin}_{ij}( M_{ij} )}}}$where Bin_(ij)(M_(ij)) is a counting function that increases a countvalue by 1 when a block mode is one of P16×16, P16×8, and P8×16, whereinwhen S(x,y)>0 an inter mode is classified into P16×16 sub-mode groupsand otherwise the inter mode is classified into P8×8 sub-mode groups;performing a first inter mode search on a block that does not correspondto one of P16×16, P16×8, and P8×16; performing a second inter modesearch on a block that corresponds to one of P16×16, P16×8, and P8×16and determining whether the macroblock of the current frame correspondsto P16×16; and performing an intra mode search if the macroblock of thecurrent frame corresponds to P16×16.
 7. The fast mode-searching methodof claim 6, further comprising: selecting a final mode obtained as aresult of the first inter mode search or the second inter mode search asa best mode if the macroblock of the current frame does not correspondto P16×16; and selecting a best mode by comparing anR-D(rate-distortion) cost of a final mode obtained as a result of thesecond inter mode search and an R-D cost of a final mode obtained as aresult of the intra mode search if the macroblock of the current framecorresponds to P16×16.
 8. The fast mode-searching method of claim 6,wherein the first inter mode search is performed in P8×8, P8×4, P4×8 andP4×4.
 9. The fast mode-searching method of claim 6, wherein the secondinter mode search is performed in P16×16, P16×8, and P8×16.
 10. The fastmode-searching method of claim 6, wherein the detection comprisesobtaining time information mode of the first P-frame of a current GOP(group-of-picture) by referring to the last P-frame of a previous GOP.11. A non-transitory computer readable medium having coded instructionsfor carrying out a fast mode-searching method for performing fastmotion-prediction, the coded instructions of the fast mode-searchingmethod comprising: coded instructions for detecting using a scorefunction S(x,y) to determine whether at least one of a macroblock of aprevious frame, a macroblock of a current frame, and adjacentmacroblocks corresponds to P16×16 sub-mode groups comprising at leastone of P16×16, P16×8, and P8×16, or corresponds to P8×8 sub-mode groupscomprising at least one of P8×8, P8×4, P4×8, and P4×4 in which${S( {x,y} )} = {{\underset{{({i,j})}{Hpreviousframe}}{Q}{{Bin}_{ij}( M_{ij} )}} + {\underset{{({i,j})}{Hcurrentframe}}{Q}{{Bin}_{ij}( M_{ij} )}}}$where Bin_(ij)(M_(ij)) is a counting function that increases a countvalue by 1 when a block mode is one of P16×16, P16×8, and P8×16 whereinwhen S(x,y)>0 an inter mode is classified into P16×16 sub-mode groupsand otherwise the inter mode is classified into P8×8 sub-mode groups;coded instructions for performing a first inter mode search on a blockthat does not correspond to one of P16×16, P16×8, and P8×16; codedinstructions performing a second inter mode search on a block thatcorresponds to one of P16×16, P16×8, and P8×16 and determining whetherthe macroblock of the current frame corresponds to P16×16; and codedinstructions performing an intra mode search if the macroblock of thecurrent frame corresponds to P16×16.
 12. The non-transitory computerreadable medium of claim 11, further comprising: coded instructionsselecting a final mode obtained as a result of the first inter modesearch or the second inter mode search as a best mode if the macroblockof the current frame does not correspond to P16×16; and codedinstructions selecting a best mode by comparing an R-D(rate-distortion)cost of a final mode obtained as a result of the second inter modesearch and an R-D cost of a final mode obtained as a result of the intramode search if the macroblock of the current frame corresponds toP16×16.
 13. The non-transitory computer readable medium of claim 11,wherein the first inter mode search is performed in P8×8, P8×4, P4×8,and P4×4.
 14. The non-transitory computer readable medium of claim 11,wherein the second inter mode search is performed in P16×16, P16×8, andP8×16.
 15. The non-transitory computer readable medium of claim 11,wherein the detection comprises obtaining time information mode of thefirst P-frame of a current GOP (group-of-picture) by referring to thelast P-frame of a previous GOP.
 16. The non-transitory computer readablemedium of claim 11, wherein the non-transient computer readable mediumis selected from the group consisting of read-only memory (ROM),random-access memory (RAM), CD-ROMs, magnetic tapes, floppy disks, andoptical data storage devices.